package enterprise.manage.dao;

import enterprise.manage.entity.Products;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.hibernate.HibernateDao;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User:zhenmingyue
 * Date: 2012-11-20
 * Desc:
 */
@Repository
@Transactional
public class ProductDao extends HibernateDao<Products, Long> {
    public Products getProduct(String serialNo) {
        Query  query =createQuery("from Products where serialNo=:serialNo");
        query.setString("serialNo", serialNo);
        if(query.list().size() > 0){
            return (Products)query.list().get(0);
        }
        return null;
    }

}
